<?php
/**
 * Created by PhpStorm.
 * User: huang
 * Date: 2016/8/8
 * Time: 14:49
 */
#引入函数
include '../functions.php';
#打印数组观察
//p($_FILES);
#判断是否有post提交，防止报错
if (IS_POST){
    foreach ($_FILES as $v) {
        foreach ($v['tmp_name'] as $key => $value) {
            #判断是否是http合法上传的文件
            if (is_uploaded_file($value)){
                #找到文件后缀名，提取文件类型，方便后续操作
                $type = ltrim(strrchr($v['name'][$key],'.'),'.');
                #创建新的文件名，防止覆盖或者冲突
                $filename = time() . mt_rand(11111,99999) . '.' . $type;
                #创建上传目录
                $path = './upload/' . date('ymd');
                is_dir($path) || mkdir($path,0777,true);
                #上传路径
                $fullpath = $path . '/' . $filename;
                move_uploaded_file($v['tmp_name'][$key], $fullpath);
            }
        }
    }
}
include './upload.html';
?>